package com.qiangqiang.dao.concrete;

import com.qiangqiang.adapter.SqlAdapter;
import com.qiangqiang.entity.Clazs;
import com.qiangqiang.entity.Course;

/**
 * Created by q on 2018/3/25.
 */
public class CourseDao {

    public void insert(Course course) {
        StringBuffer sb = new StringBuffer("insert into course values(");
        sb.append(course.getCourseId() + ",").append("'" + course.getTitle() + "'" + ",").append(course.getCredits() + ")");
        new SqlAdapter().execute(sb.toString());
    }

    public void delete(int courseId) {
        StringBuffer sb = new StringBuffer("delete from course where course_id =").append(courseId);
        new SqlAdapter().execute(sb.toString());
    }

    public Course queryById(int courseId) {
        StringBuffer sb = new StringBuffer("select * from course where course_id=").append(courseId);
        return (Course) new SqlAdapter().executeQuery(sb.toString(), Course.class);
    }

}
